﻿namespace IPTableAdapters
{
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Configuration;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using System.Diagnostics;

    [HelpKeyword("vs.data.TableAdapter"), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DesignerCategory("code"), DataObject(true), GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), ToolboxItem(true)]
    public class ProjectHeadingTableAdapter : Component
    {
        private SqlDataAdapter _adapter;
        private bool _clearBeforeFill;
        private SqlCommand[] _commandCollection;
        private SqlConnection _connection;

        /*[DebuggerNonUserCode]*/
        public ProjectHeadingTableAdapter()
        {
            this.ClearBeforeFill = true;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true), HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Delete(string Original_RowPointer)
        {
            int ret;
            if (Original_RowPointer == null)
            {
                throw new ArgumentNullException("Original_RowPointer");
            }
            this.Adapter.DeleteCommand.Parameters[0].Value = Original_RowPointer;
            ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State;
            if ((this.Adapter.DeleteCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.DeleteCommand.Connection.Open();
            }
            try
            {
                ret = this.Adapter.DeleteCommand.ExecuteNonQuery();
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    this.Adapter.DeleteCommand.Connection.Close();
                }
            }
            return ret;
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode, DataObjectMethod(DataObjectMethodType.Select, true)]
        public virtual IP.ProjectHeadingDataTable GetHeaderInfo()
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            IP.ProjectHeadingDataTable dataTable = new IP.ProjectHeadingDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        [DataObjectMethod(DataObjectMethodType.Select, false), DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual IP.ProjectHeadingDataTable GetHeaderInfoByProjectCode(string ProjectCode)
        {
            this.Adapter.SelectCommand = this.CommandCollection[1];
            if (ProjectCode == null)
            {
                throw new ArgumentNullException("ProjectCode");
            }
            this.Adapter.SelectCommand.Parameters[0].Value = ProjectCode;
            IP.ProjectHeadingDataTable dataTable = new IP.ProjectHeadingDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        [DebuggerNonUserCode, DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter")]
        public virtual IP.ProjectHeadingDataTable GetHeaderInfoByProjectCodeBySection(int AlertDay, string ProjectCode, int? Section)
        {
            this.Adapter.SelectCommand = this.CommandCollection[2];
            this.Adapter.SelectCommand.Parameters[0].Value = AlertDay;
            if (ProjectCode == null)
            {
                throw new ArgumentNullException("ProjectCode");
            }
            this.Adapter.SelectCommand.Parameters[1].Value = ProjectCode;
            if (Section.HasValue)
            {
                this.Adapter.SelectCommand.Parameters[2].Value = Section.Value;
            }
            else
            {
                this.Adapter.SelectCommand.Parameters[2].Value = DBNull.Value;
            }
            IP.ProjectHeadingDataTable dataTable = new IP.ProjectHeadingDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        /*[DebuggerNonUserCode]*/
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping tableMapping = new DataTableMapping();
            tableMapping.SourceTable = "Table";
            tableMapping.DataSetTable = "ProjectHeading";
            tableMapping.ColumnMappings.Add("ProjectCode", "ProjectCode");
            tableMapping.ColumnMappings.Add("HeadingCode", "HeadingCode");
            tableMapping.ColumnMappings.Add("HeadingName", "HeadingName");
            tableMapping.ColumnMappings.Add("Section", "Section");
            tableMapping.ColumnMappings.Add("Action", "Action");
            tableMapping.ColumnMappings.Add("DocumentNumber", "DocumentNumber");
            tableMapping.ColumnMappings.Add("Status", "Status");
            tableMapping.ColumnMappings.Add("Remark", "Remark");
            tableMapping.ColumnMappings.Add("ACMEDueDate", "ACMEDueDate");
            tableMapping.ColumnMappings.Add("AgentDueDate", "AgentDueDate");
            tableMapping.ColumnMappings.Add("CompletionDate", "CompletionDate");
            tableMapping.ColumnMappings.Add("ResponsibleBy", "ResponsibleBy");
            tableMapping.ColumnMappings.Add("Remark1", "Remark1");
            tableMapping.ColumnMappings.Add("Remark2", "Remark2");
            tableMapping.ColumnMappings.Add("Remark3", "Remark3");
            tableMapping.ColumnMappings.Add("Remark4", "Remark4");
            tableMapping.ColumnMappings.Add("Remark5", "Remark5");
            tableMapping.ColumnMappings.Add("DateFld1", "DateFld1");
            tableMapping.ColumnMappings.Add("DateFld2", "DateFld2");
            tableMapping.ColumnMappings.Add("DateFld3", "DateFld3");
            tableMapping.ColumnMappings.Add("DateFld4", "DateFld4");
            tableMapping.ColumnMappings.Add("DateFld5", "DateFld5");
            tableMapping.ColumnMappings.Add("DeciFld1", "DeciFld1");
            tableMapping.ColumnMappings.Add("DeciFld2", "DeciFld2");
            tableMapping.ColumnMappings.Add("CreateBy", "CreateBy");
            tableMapping.ColumnMappings.Add("UpdateBy", "UpdateBy");
            tableMapping.ColumnMappings.Add("OwnerGroupID", "OwnerGroupID");
            tableMapping.ColumnMappings.Add("FromTemplateYN", "FromTemplateYN");
            tableMapping.ColumnMappings.Add("IsLastProgress", "IsLastProgress");
            tableMapping.ColumnMappings.Add("Sequence", "Sequence");
            tableMapping.ColumnMappings.Add("RowPointer", "RowPointer");
            this._adapter.TableMappings.Add(tableMapping);
            this._adapter.DeleteCommand = new SqlCommand();
            this._adapter.DeleteCommand.Connection = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM [ProjectHeading] WHERE (([RowPointer] = @Original_RowPointer))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_RowPointer", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "RowPointer", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.InsertCommand = new SqlCommand();
            this._adapter.InsertCommand.Connection = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO ProjectHeading\r\n                      (ProjectCode, HeadingCode, HeadingName, Section, DocumentNumber, Status, Remark, ACMEDueDate, AgentDueDate, CompletionDate, \r\n                      ResponsibleBy, Remark1, Remark2, Remark3, Remark4, Remark5, DateFld1, DateFld2, DateFld3, DateFld4, DateFld5, DeciFld1, DeciFld2, CreateBy, \r\n                      UpdateBy, OwnerGroupID, FromTemplateYN, Sequence, RowPointer)\r\nVALUES     (@ProjectCode,@HeadingCode,@HeadingName,@Section,@DocumentNumber,@Status,@Remark,@ACMEDueDate,@AgentDueDate,@CompletionDate,@ResponsibleBy,@Remark1,@Remark2,@Remark3,@Remark4,@Remark5,@DateFld1,@DateFld2,@DateFld3,@DateFld4,@DateFld5,@DeciFld1,@DeciFld2,@CreateBy,@UpdateBy,@OwnerGroupID,@FromTemplateYN,@Sequence,\r\n                       NEWID())";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ProjectCode", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ProjectCode", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@HeadingCode", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "HeadingCode", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@HeadingName", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "HeadingName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Section", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "Section", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DocumentNumber", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "DocumentNumber", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Status", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Remark", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ACMEDueDate", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "ACMEDueDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@AgentDueDate", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "AgentDueDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CompletionDate", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "CompletionDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ResponsibleBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ResponsibleBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Remark1", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Remark2", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Remark3", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark3", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Remark4", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark4", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Remark5", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark5", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DateFld1", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DateFld2", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DateFld3", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld3", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DateFld4", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld4", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DateFld5", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld5", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DeciFld1", SqlDbType.Decimal, 13, ParameterDirection.Input, 0x15, 10, "DeciFld1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@DeciFld2", SqlDbType.Decimal, 13, ParameterDirection.Input, 0x15, 10, "DeciFld2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CreateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "CreateBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@UpdateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "UpdateBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@OwnerGroupID", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "OwnerGroupID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@FromTemplateYN", SqlDbType.Bit, 1, ParameterDirection.Input, 0, 0, "FromTemplateYN", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Sequence", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "Sequence", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand = new SqlCommand();
            this._adapter.UpdateCommand.Connection = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE    ProjectHeading\r\nSET              HeadingName = @HeadingName, Section = @Section, DocumentNumber = @DocumentNumber, Status = @Status, Remark = @Remark, \r\n                      ACMEDueDate = @ACMEDueDate, AgentDueDate = @AgentDueDate, CompletionDate = @CompletionDate, ResponsibleBy = @ResponsibleBy, \r\n                      Remark1 = @Remark1, Remark2 = @Remark2, Remark3 = @Remark3, Remark4 = @Remark4, Remark5 = @Remark5, DateFld1 = @DateFld1, \r\n                      DateFld2 = @DateFld2, DateFld3 = @DateFld3, DateFld4 = @DateFld4, DateFld5 = @DateFld5, DeciFld1 = @DeciFld1, DeciFld2 = @DeciFld2, \r\n                      UpdateBy = @UpdateBy, UpdateDate = GETDATE(), Sequence = @Sequence\r\nWHERE     (RowPointer = @Original_RowPointer)";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@HeadingName", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "HeadingName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Section", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "Section", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DocumentNumber", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "DocumentNumber", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Status", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Remark", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ACMEDueDate", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "ACMEDueDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@AgentDueDate", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "AgentDueDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CompletionDate", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "CompletionDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ResponsibleBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ResponsibleBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Remark1", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Remark2", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Remark3", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark3", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Remark4", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark4", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Remark5", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Remark5", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DateFld1", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DateFld2", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DateFld3", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld3", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DateFld4", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld4", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DateFld5", SqlDbType.DateTime, 8, ParameterDirection.Input, 0, 0, "DateFld5", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DeciFld1", SqlDbType.Decimal, 13, ParameterDirection.Input, 0x15, 10, "DeciFld1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@DeciFld2", SqlDbType.Decimal, 13, ParameterDirection.Input, 0x15, 10, "DeciFld2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@UpdateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "UpdateBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Sequence", SqlDbType.VarChar, 4, ParameterDirection.Input, 0, 0, "Sequence", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_RowPointer", SqlDbType.UniqueIdentifier, 0x10, ParameterDirection.Input, 0, 0, "RowPointer", DataRowVersion.Original, false, null, "", "", ""));
        }

        /*[DebuggerNonUserCode]*/
        private void InitCommandCollection()
        {
            this._commandCollection = new SqlCommand[3];
            this._commandCollection[0] = new SqlCommand();
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "SELECT     ProjectCode, HeadingCode, HeadingName, Section, Action, DocumentNumber, Status, Remark, ACMEDueDate, AgentDueDate, CompletionDate, \r\n                      ResponsibleBy, Remark1, Remark2, Remark3, Remark4, Remark5, DateFld1, DateFld2, DateFld3, DateFld4, DateFld5, DeciFld1, DeciFld2, CreateBy, \r\n                      UpdateBy, OwnerGroupID, FromTemplateYN, ISNULL(IsLastProgress, 0) AS IsLastProgress, Sequence, RowPointer\r\nFROM         ProjectHeading\r\nORDER BY Sequence";
            this._commandCollection[0].CommandType = CommandType.Text;
            this._commandCollection[1] = new SqlCommand();
            this._commandCollection[1].Connection = this.Connection;
            this._commandCollection[1].CommandText = "SELECT ACMEDueDate, Action, AgentDueDate, CompletionDate, CreateBy, DateFld1, DateFld2, DateFld3, DateFld4, DateFld5, DeciFld1, DeciFld2, DocumentNumber, FromTemplateYN, HeadingCode, HeadingName, ISNULL(IsLastProgress, 0) AS IsLastProgress, OwnerGroupID, ProjectCode, Remark, Remark1, Remark2, Remark3, Remark4, Remark5, ResponsibleBy, RowPointer, Section, Sequence, Status, UpdateBy FROM ProjectHeading WHERE (ProjectCode = @ProjectCode)";
            this._commandCollection[1].CommandType = CommandType.Text;
            this._commandCollection[1].Parameters.Add(new SqlParameter("@ProjectCode", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ProjectCode", DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[2] = new SqlCommand();
            this._commandCollection[2].Connection = this.Connection;
            this._commandCollection[2].CommandText = "SELECT     ACMEDueDate, Action, AgentDueDate, CompletionDate, CreateBy, DateFld1, DateFld2, DateFld3, DateFld4, DateFld5, DeciFld1, DeciFld2, \r\n                      DocumentNumber, FromTemplateYN, HeadingCode, HeadingName, ISNULL(IsLastProgress, 0) AS IsLastProgress, OwnerGroupID, ProjectCode, \r\n                      Remark, Remark1, Remark2, Remark3, Remark4, Remark5, ResponsibleBy, RowPointer, Section, Sequence, Status, UpdateBy, \r\n                      dbo.IsProjectHeadingOverDue(ACMEDueDate, @AlertDay) AS OverDue\r\nFROM         ProjectHeading\r\nWHERE     (ProjectCode = @ProjectCode) AND (Section = @Section)\r\nORDER BY Sequence";
            this._commandCollection[2].CommandType = CommandType.Text;
            this._commandCollection[2].Parameters.Add(new SqlParameter("@AlertDay", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "", DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[2].Parameters.Add(new SqlParameter("@ProjectCode", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ProjectCode", DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[2].Parameters.Add(new SqlParameter("@Section", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "Section", DataRowVersion.Current, false, null, "", "", ""));
        }

        /*[DebuggerNonUserCode]*/
        private void InitConnection()
        {
            this._connection = new SqlConnection();
            this._connection.ConnectionString = ConfigurationManager.ConnectionStrings["LocalSqlConnection1"].ConnectionString;
        }

        [DataObjectMethod(DataObjectMethodType.Insert, true), DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Insert(string ProjectCode, string HeadingCode, string HeadingName, int? Section, string DocumentNumber, string Status, string Remark, DateTime? ACMEDueDate, DateTime? AgentDueDate, DateTime? CompletionDate, string ResponsibleBy, string Remark1, string Remark2, string Remark3, string Remark4, string Remark5, DateTime? DateFld1, DateTime? DateFld2, DateTime? DateFld3, DateTime? DateFld4, DateTime? DateFld5, decimal? DeciFld1, decimal? DeciFld2, string CreateBy, string UpdateBy, string OwnerGroupID, bool? FromTemplateYN, int? Sequence)
        {
            int ret;
            if (ProjectCode == null)
            {
                throw new ArgumentNullException("ProjectCode");
            }
            this.Adapter.InsertCommand.Parameters[0].Value = ProjectCode;
            if (HeadingCode == null)
            {
                throw new ArgumentNullException("HeadingCode");
            }
            this.Adapter.InsertCommand.Parameters[1].Value = HeadingCode;
            if (HeadingName == null)
            {
                this.Adapter.InsertCommand.Parameters[2].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[2].Value = HeadingName;
            }
            if (Section.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[3].Value = Section.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[3].Value = DBNull.Value;
            }
            if (DocumentNumber == null)
            {
                this.Adapter.InsertCommand.Parameters[4].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[4].Value = DocumentNumber;
            }
            if (Status == null)
            {
                throw new ArgumentNullException("Status");
            }
            this.Adapter.InsertCommand.Parameters[5].Value = Status;
            if (Remark == null)
            {
                this.Adapter.InsertCommand.Parameters[6].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[6].Value = Remark;
            }
            if (ACMEDueDate.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[7].Value = ACMEDueDate.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[7].Value = DBNull.Value;
            }
            if (AgentDueDate.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[8].Value = AgentDueDate.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[8].Value = DBNull.Value;
            }
            if (CompletionDate.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[9].Value = CompletionDate.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[9].Value = DBNull.Value;
            }
            if (ResponsibleBy == null)
            {
                this.Adapter.InsertCommand.Parameters[10].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[10].Value = ResponsibleBy;
            }
            if (Remark1 == null)
            {
                this.Adapter.InsertCommand.Parameters[11].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[11].Value = Remark1;
            }
            if (Remark2 == null)
            {
                this.Adapter.InsertCommand.Parameters[12].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[12].Value = Remark2;
            }
            if (Remark3 == null)
            {
                this.Adapter.InsertCommand.Parameters[13].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[13].Value = Remark3;
            }
            if (Remark4 == null)
            {
                this.Adapter.InsertCommand.Parameters[14].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[14].Value = Remark4;
            }
            if (Remark5 == null)
            {
                this.Adapter.InsertCommand.Parameters[15].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[15].Value = Remark5;
            }
            if (DateFld1.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x10].Value = DateFld1.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x10].Value = DBNull.Value;
            }
            if (DateFld2.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x11].Value = DateFld2.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x11].Value = DBNull.Value;
            }
            if (DateFld3.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x12].Value = DateFld3.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x12].Value = DBNull.Value;
            }
            if (DateFld4.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x13].Value = DateFld4.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x13].Value = DBNull.Value;
            }
            if (DateFld5.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[20].Value = DateFld5.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[20].Value = DBNull.Value;
            }
            if (DeciFld1.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x15].Value = DeciFld1.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x15].Value = DBNull.Value;
            }
            if (DeciFld2.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x16].Value = DeciFld2.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x16].Value = DBNull.Value;
            }
            if (CreateBy == null)
            {
                throw new ArgumentNullException("CreateBy");
            }
            this.Adapter.InsertCommand.Parameters[0x17].Value = CreateBy;
            if (UpdateBy == null)
            {
                throw new ArgumentNullException("UpdateBy");
            }
            this.Adapter.InsertCommand.Parameters[0x18].Value = UpdateBy;
            if (OwnerGroupID == null)
            {
                throw new ArgumentNullException("OwnerGroupID");
            }
            this.Adapter.InsertCommand.Parameters[0x19].Value = OwnerGroupID;
            if (FromTemplateYN.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x1a].Value = FromTemplateYN.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x1a].Value = DBNull.Value;
            }
            if (Sequence.HasValue)
            {
                this.Adapter.InsertCommand.Parameters[0x1b].Value = Sequence.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x1b].Value = DBNull.Value;
            }
            ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State;
            if ((this.Adapter.InsertCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.InsertCommand.Connection.Open();
            }
            try
            {
                ret = this.Adapter.InsertCommand.ExecuteNonQuery();
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    this.Adapter.InsertCommand.Connection.Close();
                }
            }
            return ret;
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(IP dataSet)
        {
            return this.Adapter.Update(dataSet, "ProjectHeading");
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Update(DataRow[] dataRows)
        {
            return this.Adapter.Update(dataRows);
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(IP.ProjectHeadingDataTable dataTable)
        {
            return this.Adapter.Update(dataTable);
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(DataRow dataRow)
        {
            return this.Adapter.Update(new DataRow[] { dataRow });
        }

        [DataObjectMethod(DataObjectMethodType.Update, true), DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Update(string HeadingName, int? Section, string DocumentNumber, string Status, string Remark, DateTime? ACMEDueDate, DateTime? AgentDueDate, DateTime? CompletionDate, string ResponsibleBy, string Remark1, string Remark2, string Remark3, string Remark4, string Remark5, DateTime? DateFld1, DateTime? DateFld2, DateTime? DateFld3, DateTime? DateFld4, DateTime? DateFld5, decimal? DeciFld1, decimal? DeciFld2, string UpdateBy, string Sequence, Guid Original_RowPointer)
        {
            int ret;
            if (HeadingName == null)
            {
                this.Adapter.UpdateCommand.Parameters[0].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0].Value = HeadingName;
            }
            if (Section.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[1].Value = Section.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[1].Value = DBNull.Value;
            }
            if (DocumentNumber == null)
            {
                this.Adapter.UpdateCommand.Parameters[2].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[2].Value = DocumentNumber;
            }
            if (Status == null)
            {
                throw new ArgumentNullException("Status");
            }
            this.Adapter.UpdateCommand.Parameters[3].Value = Status;
            if (Remark == null)
            {
                this.Adapter.UpdateCommand.Parameters[4].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[4].Value = Remark;
            }
            if (ACMEDueDate.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[5].Value = ACMEDueDate.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[5].Value = DBNull.Value;
            }
            if (AgentDueDate.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[6].Value = AgentDueDate.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[6].Value = DBNull.Value;
            }
            if (CompletionDate.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[7].Value = CompletionDate.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[7].Value = DBNull.Value;
            }
            if (ResponsibleBy == null)
            {
                this.Adapter.UpdateCommand.Parameters[8].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[8].Value = ResponsibleBy;
            }
            if (Remark1 == null)
            {
                this.Adapter.UpdateCommand.Parameters[9].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[9].Value = Remark1;
            }
            if (Remark2 == null)
            {
                this.Adapter.UpdateCommand.Parameters[10].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[10].Value = Remark2;
            }
            if (Remark3 == null)
            {
                this.Adapter.UpdateCommand.Parameters[11].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[11].Value = Remark3;
            }
            if (Remark4 == null)
            {
                this.Adapter.UpdateCommand.Parameters[12].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[12].Value = Remark4;
            }
            if (Remark5 == null)
            {
                this.Adapter.UpdateCommand.Parameters[13].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[13].Value = Remark5;
            }
            if (DateFld1.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[14].Value = DateFld1.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[14].Value = DBNull.Value;
            }
            if (DateFld2.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[15].Value = DateFld2.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[15].Value = DBNull.Value;
            }
            if (DateFld3.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[0x10].Value = DateFld3.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0x10].Value = DBNull.Value;
            }
            if (DateFld4.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[0x11].Value = DateFld4.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0x11].Value = DBNull.Value;
            }
            if (DateFld5.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[0x12].Value = DateFld5.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0x12].Value = DBNull.Value;
            }
            if (DeciFld1.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[0x13].Value = DeciFld1.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0x13].Value = DBNull.Value;
            }
            if (DeciFld2.HasValue)
            {
                this.Adapter.UpdateCommand.Parameters[20].Value = DeciFld2.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[20].Value = DBNull.Value;
            }
            if (UpdateBy == null)
            {
                throw new ArgumentNullException("UpdateBy");
            }
            this.Adapter.UpdateCommand.Parameters[0x15].Value = UpdateBy;
            if (Sequence == null)
            {
                this.Adapter.UpdateCommand.Parameters[0x16].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0x16].Value = Sequence;
            }
            this.Adapter.UpdateCommand.Parameters[0x17].Value = Original_RowPointer;
            ConnectionState previousConnectionState = this.Adapter.UpdateCommand.Connection.State;
            if ((this.Adapter.UpdateCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.UpdateCommand.Connection.Open();
            }
            try
            {
                ret = this.Adapter.UpdateCommand.ExecuteNonQuery();
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    this.Adapter.UpdateCommand.Connection.Close();
                }
            }
            return ret;
        }

        /*[DebuggerNonUserCode]*/
        private SqlDataAdapter Adapter
        {
            get
            {
                if (this._adapter == null)
                {
                    this.InitAdapter();
                }
                return this._adapter;
            }
        }

        /*[DebuggerNonUserCode]*/
        public bool ClearBeforeFill
        {
            get
            {
                return this._clearBeforeFill;
            }
            set
            {
                this._clearBeforeFill = value;
            }
        }

        /*[DebuggerNonUserCode]*/
        protected SqlCommand[] CommandCollection
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
        }

        /*[DebuggerNonUserCode]*/
        internal SqlConnection Connection
        {
            get
            {
                if (this._connection == null)
                {
                    this.InitConnection();
                }
                return this._connection;
            }
            set
            {
                this._connection = value;
                if (this.Adapter.InsertCommand != null)
                {
                    this.Adapter.InsertCommand.Connection = value;
                }
                if (this.Adapter.DeleteCommand != null)
                {
                    this.Adapter.DeleteCommand.Connection = value;
                }
                if (this.Adapter.UpdateCommand != null)
                {
                    this.Adapter.UpdateCommand.Connection = value;
                }
                for (int i = 0; i < this.CommandCollection.Length; i++)
                {
                    if (this.CommandCollection[i] != null)
                    {
                        this.CommandCollection[i].Connection = value;
                    }
                }
            }
        }
    }
}

